home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / mlht02.zip / Homepg4.bas < prev    next >
BASIC Source File  |  1996-07-01  |  4KB  |  180 lines

  1. '-----------------------------------------------
  2. '   Subroutine to clear user selections
  3. '-----------------------------------------------
  4. sub ClearPicks()
  5.   for i = 1 to 80
  6.     userPick[i] = 0
  7.   next i
  8.   winners = 0
  9.   return
  10. end sub
  11.  
  12. '-----------------------------------------------
  13. '   Subroutine to draw control 'buttons'
  14. '-----------------------------------------------
  15. sub drawButtons()
  16.   PenColor 0,155,0
  17.   DrawRect 0,160,200,40,FILLED
  18.   PenColor 0,0,0
  19.   PenWidth 3
  20.   DrawRect 0,160,200,40
  21.   TextColor 0,0,0
  22.   SetFont "Dialog",14
  23.   DrawText "GO!",80,180
  24.  
  25.   PenColor 0,64,192
  26.   DrawRect 0,200,200,40,FILLED
  27.   PenColor 0,0,0
  28.   PenWidth 3
  29.   DrawRect 0,200,200,40
  30.   TextColor 0,0,0
  31.   SetFont "Dialog",14
  32.   DrawText "Reset",80,220
  33.  
  34.   return
  35. end sub
  36.  
  37. '-----------------------------------------------
  38. '   Subroutine to draw the keno board
  39. '-----------------------------------------------
  40. sub drawBoard()
  41.  
  42. PenWidth 2
  43. i = 1
  44. SetFont "TimesRoman",10
  45. TextColor 255,255,0
  46. for y=1 to 8
  47.   for x = 0 to 9
  48.     'print x,y
  49.     PenColor 255,0,0
  50.     DrawRect x*20,(y-1)*20,20,20,FILLED
  51.     PenColor 0,0,0
  52.     DrawRect x*20,(y-1)*20,20,20
  53.     DrawText i,x*20+5,(y-1)*20+10
  54.     '
  55.     ' now, let's save the xy position for each
  56.     ' square in two varrays for ease of use later
  57.     '
  58.     locX[((y-1)*10)+x+1] = x*20
  59.     locY[((y-1)*10)+x+1] = (y-1)*20
  60.     i = i + 1
  61.   next x
  62. next y
  63. return
  64. end sub
  65.  
  66. '-----------------------------------------------
  67. '   Subroutine to pick and draw the winners!
  68. '-----------------------------------------------
  69. sub PickWinners()
  70.  
  71. for j=1 to 20
  72.   picks[j] = 0
  73. next j
  74.  
  75. nextpick = 1
  76.  
  77. SetFont "TimesRoman",10
  78.  
  79. myloop: q=int(rnd()*80)+1
  80.    found = 0
  81.  
  82.    for j = 1 to 20
  83.      if q = picks[j]
  84.        found = j
  85.      end if
  86.    next j
  87.  
  88.    if found <> 0
  89.      q = q
  90.    else
  91.      picks[nextpick] = q
  92.      nextpick = nextpick + 1
  93.      if userPick[q] = 0 then
  94.        PenColor 225,228,0
  95.        TextColor 0,0,0
  96.      else
  97.        PenColor 0,0,255
  98.        TextColor 255,255,255
  99.        winners = winners + 1
  100.      endif
  101.  
  102.      x = locX[q]
  103.      y = locY[q]
  104.      DrawRect x+1,y+1,18,18,FILLED
  105.      DrawText q,x+5,y+10
  106.    end if
  107.  
  108.    if nextpick <= 20
  109.      goto myloop
  110.    endif
  111.  
  112. PenColor 255,255,255
  113. DrawRect 0,240,200,20,FILLED
  114. TextColor 0,0,0
  115. DrawText "You Had " ! winners ! " winners!",50,250
  116.  
  117. end sub
  118.  
  119.  
  120. '-----------------------------------------------
  121. '   Subroutine to handle mouse clicks
  122. '-----------------------------------------------
  123. sub mouse_click()
  124.  
  125.   '
  126.   ' convert the mouse coordinate to 'square' coordinates
  127.   '
  128.   x = int(xparm / 20)+1;
  129.   y = int(yparm / 20)+1;
  130.  
  131.   '
  132.   ' did the user pick the virtual 'GO' button?
  133.   '
  134.   if (y = 9) | (y = 10) then
  135.     call PickWinners
  136.     return
  137.   endif
  138.  
  139.   '
  140.   ' did the user pick the virtual 'RESET' button?
  141.   '
  142.   if y >= 11 then
  143.     PenColor 255,255,255
  144.     DrawRect 0,240,200,20,FILLED
  145.     TextColor 0,0,0
  146.     DrawText "HotTEA 2.0 Keno!",50,250
  147.     call drawButtons
  148.     call clearPicks
  149.     call drawBoard
  150.     return
  151.   endif
  152.  
  153.   'print "click on ",x,",",y
  154.  
  155.   square = ((y-1)*10)+x
  156.   userPick[square] = 1
  157.  
  158.   dx = locX[square]
  159.   dy = locY[square]
  160.  
  161.   PenColor 0,255,0
  162.   DrawRect dx,dy,20,20
  163.  
  164. end sub
  165.  
  166. '-----------------------------------------------
  167. '
  168. '   Main program
  169. '
  170. '-----------------------------------------------
  171. sub main()
  172.   PenColor 255,255,255
  173.   DrawRect 0,240,200,20,FILLED
  174.   TextColor 0,0,0
  175.   DrawText "HotTEA 2.0 Keno!",50,250
  176.   call drawButtons
  177.   call clearPicks
  178.   call drawBoard
  179. end sub
  180.